home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kgame / kgamesequence.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.6 KB  |  88 lines

  1. /*
  2.     This file is part of the KDE games library
  3.     Copyright (C) 2003 Andreas Beckermann (b_mann@gmx.de)
  4.     Copyright (C) 2003 Martin Heni (martin@heni-online.de)
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License version 2 as published by the Free Software Foundation.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. /*
  21.     $Id: kgamesequence.h 465369 2005-09-29 14:33:08Z mueller $
  22. */
  23. #ifndef __KGAMESEQUENCE_H_
  24. #define __KGAMESEQUENCE_H_
  25.  
  26. #include <qobject.h>
  27.  
  28. class KPlayer;
  29. class KGame;
  30.  
  31. /**
  32.  * This class takes care of round or move management as well of the gameover
  33.  * condition. It is especially used for round based games. For these games @ref
  34.  * nextPlayer and @ref checkGameOver are the most important methods.
  35.  *
  36.  * You can subclass KGameSequence and use @ref KGame::setGameSequence to use
  37.  * your own rules. Note that @ref KGame will take ownership and therefore will
  38.  * delete the object on destruction.
  39.  * @short Round/move management class
  40.  * @author Andreas Beckermann <b_mann@gmx.de>
  41.  **/
  42. class KGameSequence : public QObject
  43. {
  44.     Q_OBJECT
  45. public:
  46.     KGameSequence();
  47.     virtual ~KGameSequence();
  48.  
  49.     /**
  50.      * Select the next player in a turn based game. In an asynchronous game this
  51.      * function has no meaning. Overwrite this function for your own game sequence.
  52.      * Per default it selects the next player in the playerList
  53.      */
  54.     virtual KPlayer* nextPlayer(KPlayer *last, bool exclusive = true);
  55.  
  56.     virtual void setCurrentPlayer(KPlayer* p);
  57.  
  58.     /**
  59.      * @return The @ref KGame object this sequence is for, or NULL if none.
  60.      **/
  61.     KGame* game() const { return mGame; }
  62.  
  63.     KPlayer* currentPlayer() const { return mCurrentPlayer; }
  64.  
  65.     /**
  66.      * Set the @ref KGame object for this sequence. This is called
  67.      * automatically by @ref KGame::setGameSequence and you should not call
  68.      * it.
  69.      **/
  70.     void setGame(KGame* game);
  71.  
  72.     /**
  73.      * Check whether the game is over. The default implementation always
  74.      * returns 0.
  75.      *
  76.      * @param player the player who made the last move
  77.      * @return anything else but 0 is considered as game over
  78.     **/
  79.     virtual int checkGameOver(KPlayer *player);
  80.  
  81. private:
  82.     KGame* mGame;
  83.     KPlayer* mCurrentPlayer;
  84. };
  85.  
  86. #endif
  87.  
  88.